const fs = require('fs');  

const allFileContents = fs.readFileSync('./routing.txt', 'utf-8');

var routingData = []

allFileContents.split(/\n/).forEach(line => {
  // console.log(`Line form file: ${line}`);
  let temp = {};
  let tempStr = line.substring(line.indexOf('(')+1, line.indexOf(')'));
  let valueStrs = tempStr.split(/,/);
  if(line.indexOf('moveTo') != -1){
    temp.type = "moveTo";
  }else{
    temp.type = "lineTo";
  }
  temp.value = [Number(valueStrs[0]), Number(valueStrs[1])]
  routingData.push(temp);
});

console.log(JSON.stringify(routingData))